package com.zhijiaoyun.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zhijiaoyun.controller.base.BaseController;
import com.zhijiaoyun.model.Item;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author shisfish
 * @date 2018/1/18
 */
@Controller
@RequestMapping(value = "/item", produces = "application/json; charset=utf-8")
public class ItemController extends BaseController {

    /**
     * 通过 type 查找
     * @param type
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/items")
    public Map<String, Object> items(@RequestParam(required = true) String type) {
        List<Item> items = itemService.getByType(type);

        Map<String, Object> map = new HashMap<>(CAPACITY_3);
        map.put(LIST, items);
        return  responseSuccessMap(map);
    }

}
